//首页
myApp.controller('indexController', function($scope, $controller,$timeout, $http) {
	//公司信息
	$http({
		method : 'post',
		url : '../company/findOne.action',
		data: {
			id:1
		}
	}).then(function successCallback(response) {
		$scope.compangyData = response.data;
	});
	
});
myApp.controller('homeController', function($scope, $controller,$timeout, $http) {
	//首页banner:banner 6
	$scope.bannerList = new Array();
	$http({
		method : 'post',
		url : '../image/findAll.action',
	}).then(function successCallback(response) {
		$scope.bannerData = response.data;
		for(var i=0; i<$scope.bannerData.length;i++){
	      	 if($scope.bannerData[i].type == 6){
	      		 $scope.bannerList.push($scope.bannerData[i]);
	      	 }
	    }
	});
	
	//qq号
	$http({
		method : 'post',
		url : '../company/findOne.action',
		data: {
			id:1
		}
	}).then(function successCallback(response) {
		$scope.compangyData = response.data;
	});
});
//公司介绍
myApp.controller('aboutController', function($scope, $controller,$timeout, $http,$sce,$window) {
	$http({
		method : 'post',
		url : '/introduction/findOne.action',
		data: {
			id:1
		}
	}).then(function successCallback(response) {
		$scope.introductionData = response.data;
	});
	//富文本解析
	 $scope.deliberatelyTrustDangerousSnippet = function(content) {
	        return $sce.trustAsHtml(content);
	 };
	 
	 //公司介绍banner： 2
	$http({
		method : 'post',
		url : '/image/findOneban.action',
		data: {
			id: 2
		}
	}).then(function successCallback(response) {
		$scope.introductionBanData = response.data;
		if($window.innerWidth < 768){
			angular.element('.about').css({'background' : 'url('+ $scope.introductionBanData.url +') no-repeat top center','background-size':'160%'});
		}else{
			angular.element('.about').css({'background' : 'url('+ $scope.introductionBanData.url +') no-repeat center'});
		}
	});
});
//制定小程序
myApp.controller('viController', function($scope, $controller,$timeout, $http,$sce,$window) {
	//制定小程序banner： 3
	$http({
		method : 'post',
		url : '/image/findOneban.action',
		data: {
			id: 3
		}
	}).then(function successCallback(response) {
		$scope.viBanData = response.data;
		if($window.innerWidth < 768){
			angular.element('.vibanner').css({'background' : 'url('+ $scope.viBanData.url +') no-repeat center top','background-size':'150%'});
		}else{
			angular.element('.vibanner').css({'background' : 'url('+ $scope.viBanData.url +') no-repeat center'});
		}
	});
	
	//qq号
	$http({
		method : 'post',
		url : '/company/findOne.action',
		data: {
			id:1
		}
	}).then(function successCallback(response) {
		$scope.compangyData = response.data;
	});
})
//招商联盟
myApp.controller('joinController', function($scope, $controller,$timeout, $http,$sce,$window) {
	
	$scope.itemCheck = [];
	$scope.joinCheck = "";
	$scope.checkSelect = function($event,check,data){
		var checkbox = $event.target;
	    if (checkbox.checked) {
	    	$scope.itemCheck.push(data);
	    }else{
	    	return false;
	    }
	    $scope.joinCheck = $scope.itemCheck.join("-");
	}
	//$scope.company = {name:'',contact:'',phone:'',wechat:'',message:'',type:{jinpai:"",zhuanshi:"",jinshi:"",hehuo:""}};
	$scope.company = {companyname:'',name:'',phone:'',wechat:'',type:$scope.joinCheck,message:''};

	$scope.saveJoin = function(){
		/*$scope.joinCheck = itemCheck.join("+");JSON.stringify($scope.company)*/
		if($scope.company.companyname == "" || $scope.company.name =="" || 
				$scope.company.phone =="" || $scope.company.wechat =="" || $scope.company.message =="" ){
			var txt=  "每项数据不能为空";
			window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.info);
			return;
		}
		/*String.valueOf()*/
		$scope.company.type =  $scope.joinCheck;
		$scope.data = JSON.stringify($scope.company)
		$http({
			method : 'post',
			url : '/user/add.action',
			headers: {'Content-Type': 'application/json'},
			data:JSON.stringify($scope.company),
		}).then(function successCallback(response) {
			$scope.company = {companyname:'',name:'',phone:'',wechat:'',type:"",message:''};
			var txt=  "申请发送成功";
			window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.info);
		});
	}
	
	////招商联盟banner：4
	$http({
		method : 'post',
		url : '/image/findOneban.action',
		data: {
			id: 4
		}
	}).then(function successCallback(response) {
		$scope.joinBanData = response.data;
		if($window.innerWidth < 768){
			angular.element('.joinbanner').css({'background' : 'url('+ $scope.joinBanData.url +') no-repeat center','background-size':'230%'});
		}else{
			angular.element('.joinbanner').css({'background' : 'url('+ $scope.joinBanData.url +') no-repeat center','position':'relative'});
		}
	});

	//qq号
	$http({
		method : 'post',
		url : '/company/findOne.action',
		data: {
			id:1
		}
	}).then(function successCallback(response) {
		$scope.compangyData = response.data;
	});
});
//联系我们
myApp.controller('contactController', function($scope, $controller,$timeout, $http,$sce,$window) {
////联系我们banner：5
	$http({
		method : 'post',
		url : '/image/findOneban.action',
		data: {
			id: 5
		}
	}).then(function successCallback(response) {
		$scope.contactBanData = response.data;
		if($window.innerWidth < 768){
			angular.element('.contactbanner').css({'background' : 'url('+ $scope.contactBanData.url +') no-repeat center','background-size':'170%'});
		}else{
			angular.element('.contactbanner').css({'background' : 'url('+ $scope.contactBanData.url +') no-repeat center'});
		}
	});
})

myApp.controller('usController', function($scope, $controller,$timeout, $http,$sce) {
	$http({
		method : 'post',
		url : '/contact/findOne.action',
		data: {
			id:1
		}
	}).then(function successCallback(response) {
		$scope.usData = response.data;
	});
});

myApp.controller('jobController', function($scope, $controller,$timeout, $http,$sce) {
	$http({
		method : 'post',
		url : '/recruit/findOne.action',
		data: {
			id:1
		}
	}).then(function successCallback(response) {
		$scope.jobData = response.data;
	});
	
	//富文本解析
	 $scope.deliberatelyTrustDangerousSnippet = function(content) {
	        return $sce.trustAsHtml(content);
	 };
});
